<?php 
namespace app\index\model;
use think\Db;//引入Db
use think\Model;//引入Model
class User extends Model
{
	protected $table='user';//表名
	//增加
	function insertData($data){
		return Db::table($this->table)->insertGetId($data);
	}
	//查询
	function show(){
		// var_dump($username);die;
		return Db::table($this->table)->select();    
	}
	// 查询2
	function find()
	{
		return Db::table($this->table)->where(['username'=>'王五'])->select();
	}
	//删除
	function deleteData($id){
		return Db::table($this->table)->where('id','=',$id)->delete();    
	}
	//查询单条
	function findData($id){
		return Db::table($this->table)->where('id','=',$id)->find();    
	}
	//修改
	function updateData($data,$id){
		return Db::table($this->table)->where('id','=',$id)->update($data);    
	}
}
?>